package Temp.Delete;

import java.util.ArrayList;

public class ArrayListIndex
{

	public static void maine() 
	  {
	    ArrayList<Node> arrayList = new ArrayList<Node>();

	    arrayList.add(new Node("2",2));
	    arrayList.add(new Node("3",3));
	    arrayList.add(new Node("4",4));
	    arrayList.add(new Node("5",5));
	    arrayList.add(new Node("1",1));
	    arrayList.add(new Node("2",2));

	    System.out.println(arrayList.contains("2"));

	    int index = arrayList.indexOf(new Node("4",4));
	    if (index == -1)
	      System.out.println("not contain 4");
	    else
	      System.out.println("4 at index :" + index);

	    int lastIndex = arrayList.lastIndexOf("1");
	    if (lastIndex == -1)
	      System.out.println("not contain 1");
	    else
	      System.out.println("Last index :"+ lastIndex);
	}
}

class Node
{
	String str;
	int id;
	
	public Node(String loc_str, int loc_id)
	{
		str = loc_str;
		id = loc_id;
	}
	
	public boolean equals(Object obj)
	{
		Node temp = (Node)obj;
		if(temp.str.equalsIgnoreCase(this.str))
			return true;
		else
			return false;
	}
}
